import {request as requestApi} from '../utils/requsetApi';
import { gptChatUrl } from './url'
export async function filePreviewDownload(params) {
  return requestApi({
      url: gptChatUrl.lianTongUpLoadUrlFile + '/knowledge_base/download_doc',
      method: 'GET',
      params: {
          knowledge_base_name:"dim2",
          file_name:params
      },
      responseType:"blob"
    },
  );
}
//top5
export async function getTop5() {
  return requestApi({
      url: gptChatUrl.chatUrl + '/dialogue/hotQues',
      method: 'GET',
    },
  );
}
//点赞点踩
export async function feedBack(params) {
  let form =new FormData()
  form.append('answer',JSON.stringify(params))
  return requestApi({
      url: gptChatUrl.lianTongUrl + '/basic/answer_feedback',
      method: 'POST',
      data: form
    },
  );
}
//下载
export async function tableDownload(params) {
  return requestApi({
      url: gptChatUrl.lianTongUrl + '/basic/download',
      method: 'POST',
      data: params,
      responseType:"blob"
    },
  );
}
//下载kngc  kpi_sql  里面传sql语句
export async function tableDownloadKngc(params) {
  return requestApi({
      url: gptChatUrl.lianTongUrl + '/Kngc/download',
      method: 'POST',
      data: params,
      responseType:"blob"
    },
  );
}
export async function indexPredictKngc(params) {
  console.log(params,"文件上传参数")
  return requestApi({
      url: gptChatUrl.lianTongUrl+`/Kngc/select_kpi1`,
      method: 'POST',
      data: params,
    });
/*   return {
     "kpi_name": "智能取数工具使用的联系人是计楠，联系方式如下：\n\n- 电话：18651883077\n- 邮箱：jin6@chinaunicom.cn",
     "resp_code": "00000",
     "page_content": [
       "出处 [1] [None] \n\n4.1 点击查询经常没反应？答：数据加工时间一般在 3min\n\n7min。\n\n4.2 配置维度后显示模型不存在？答：联系我们在 hashdata 进行数据导入\n\n提数需求\n\n使用智能取数\n\n工具\n\n分析基础指标\n\n智能取数工具使用流程\n\n和维度\n\n查询基础指标是否具\n\n备\n\n否\n\n基础指标配置\n\n工具使用有任何疑问\n\n联系我：\n\n是\n\n计楠18651883077\n\n查询维度是否具备\n\n否\n\n分析维度是否取至同\n\n常态化加工维\n\n个明细打标表\n\n度明细打标表\n\n判断是否需要导数\n\n推数至cube\n\n维度配置\n\n维值配置\n\n自助取数\n\n结束第 5 章 联系我们\n\n如在使用过程中遇到任何问题，欢迎通过以下方式联系我们：\n\n\n\n电话：计楠  18651883077\n\n\n\n邮箱 jin6@chinaunicom.cn\n\n",
       "出处 [2] [None] \n\n智能指标平台操作手册 第 1 章 平台简介 1.1 智能指标平台是一款用于数据采集和处理的平台工具，通过引入知识库、RAG（检索增强）、 以及 NLP2SQL（自然语言处理到 SQL 转换）等 ai 技术，显著提升数据供给全流程智能化水平。 赋能数据建模、数据分析等场景，解决开发人员找口径困难，重复开发工作多等问题，加快数 据供给速度。为业务部门提供敏捷、精准数据支持。 第 2 章 操作流程\n\n2.1 登录平台\n\n1.\n\n打开取数平台。\n\n2.\n\n输入用户名和密码，点击“登录”。\n\n2.2 查询基本指标\n\n1.\n\n对话页面。\n\n2.\n\n直接输入指标名称。支持不同单个省份、账期（202312\n\n至今）\n\neg.20240622 账期宽带接入网上用户数;河北省的移动业务发展用户数\n\n2.3 查询多维指标\n\n1.\n\n对话页面。\n\n2.\n\n输入选择的维度以及查询指标。\n\neg.维度：细分市场类型，是否专线 指标：政企渠道宽带网上用户\n\n2.4 计算基本指标\n\n1.\n\n对话页面。\n\n2.\n\n以计算开头输入基本指标的四则运算。\n\neg.维度：计算(5G 出账用户数+4G 出账用户数)/4G 出账用户数\n\n2.5 查询拍照观察指标 1.对话页面。 2.以拍照 xxxkpi 观察 xxxkpi 的格式输入指标 3. eg.拍照维度：细分市场类型，是否专线 指标：202401 政企渠道宽带网上用户观察维度： 细分市场类型，是否专线 指标：202404 宽带出账收入\n\n说明：输入的拍照指标和观察指标如需要查询维度信息，两边的维度信息需要保持一致\n\n",
       "出处 [3] [None] \n\n说明：输入的拍照指标和观察指标如需要查询维度信息，两边的维度信息需要保持一致\n\n2.6 血缘查询 1.对话页面。 2. 以 分析 xxx 模型/维度影响的指标 格式进行查询 eg.分析维度:是否三无的血缘影响的指标 分析模型:DWA_V_M_CUS_CB_USER_INFO 的血缘影响的指标\n\n说明：目前仅支持维度以及模型的血缘查询\n\n2.7 下载数据\n\n1.在对话页面查询指标或者血缘数据\n\n2.点击下方点我进行数据生成进行数据下载（excel 格式）\n\n说明：对话页面最多展现 50 行数据，如需获取全部数据需要进行下载\n\n2.8 知识管理\n\n1. 对话页面左侧功能栏点击维度管理\n\n2. 对维度、维值以及基本指标进行增删改查的操作\n\n说明：以维度：细分市场类型，是否专线 指标：政企渠道宽带网上用户为例，维度是细分市场\n\n类型，是否专线；维值是政企渠道、宽带接入、网上；基本指标是用户数\n\n2.9 新建会话\n\n1.对话页面左侧功能栏点击新建会话\n\n2.10 历史会话\n\n1.对话页面左侧功能栏点击历史会话\n\n2.11 热门指标推荐\n\n说明：会根据常用指标在首页进行推荐\n\n2.12 本地文档上传分析（待开发）\n\n2.13 用户反馈\n\n1. 对话页面左侧功能栏点击用户管理选择用户反馈\n\n2. 在弹出框填写反馈意见\n\n第 3 章 智能取数平台提数流程\n\n第 4 章 常见问题解答\n\n4.1 点击查询经常没反应？答：数据加工时间一般在 3min\n\n7min。\n\n4.2 配置维度后显示模型不存在？答：联系我们在 hashdata 进行数据导入\n\n提数需求\n\n使用智能取数\n\n工具\n\n分析基础指标\n\n智能取数工具使用流程\n\n和维度\n\n查询基础指标是否具\n\n备\n\n否\n\n基础指标配置\n\n"
     ]
   }*/
}
//指标预查询
export async function indexPredict(params) {
  return requestApi({
    url: gptChatUrl.lianTongUrl+`/basic/select_kpi1`,
    method: 'GET',
    params: params,
  });
/*    return {
      "kpi_name": "移动业务发展用户数",
      "prov_name": "北京",
      "resp_code": "00000",
      "date_id": "202401",
      "ai_desc":"",
      "final_kpi_sql": "",
      "kpi_sql": "",
      "vtable_sql": ""
    }*/
}
// 指标查询
export async function indexSearch(params) {
  return requestApi({
    url: gptChatUrl.lianTongUrl+`/basic/select_kpi`,
    method: 'post',
    data: params,
  });
   /* return {
      "input": [
        [
          "202405",
          "内蒙古",
          175301
        ],
        [
          "202405",
          "北京",
          169065
        ],
        [
          "202405",
          "天津",
          112118
        ],
        [
          "202405",
          "山东",
          467714
        ],
      ],
      "kpi_name": "移动业务发展用户数",
      "prov_name": "31省",
      "resp_code": "00000",
      "input_column": [
        "账期",
        "省分",
        "当期值"
      ],
      "date_id": "202405",
      "kpi_desc": "您好，为您智能提取的指标是 移动业务发展用户数\n指标结果数据如下：\n下载指标数据表",
      "kpi_sql": "select month_id,prov_id,kpi_value from cube.dm_M_kpi_al_comp_s WHERE area_Id= '-1' and month_id = '202405' and kpi_code = 'CKP_25252'and prov_id  in ('010','011','013','017','018','019','030','031','034','036','038','050','051','059','070','071','074','075','076','079','081','083','084','085','086','087','088','089','090','091','097','111','112','113')"
    }*/

}
export async function indexSearchKngc(params) {
    return requestApi({
      url: gptChatUrl.lianTongUrl+`/Kngc/select_kpi`,
      method: 'post',
      data: params,
    });
/*  return {
    "input": [
      [
        "202405",
        "内蒙古",
        175301
      ],
      [
        "202405",
        "北京",
        169065
      ],
      [
        "202405",
        "天津",
        112118
      ],
      [
        "202405",
        "山东",
        467714
      ],
    ],
    "kpi_name": "移动业务发展用户数",
    "prov_name": "31省",
    "resp_code": "00000",
    "input_column": [
      "账期",
      "省分",
      "当期值"
    ],
    "date_id": "202405",
    "kpi_desc": "您好，为您智能提取的指标是 移动业务发展用户数\n指标结果数据如下：\n下载指标数据表",
    "kpi_sql": "select month_id,prov_id,kpi_value from cube.dm_M_kpi_al_comp_s WHERE area_Id= '-1' and month_id = '202405' and kpi_code = 'CKP_25252'and prov_id  in ('010','011','013','017','018','019','030','031','034','036','038','050','051','059','070','071','074','075','076','079','081','083','084','085','086','087','088','089','090','091','097','111','112','113')"
  }*/

}
// 新增会话、继续某条历史会话
export async function addDialogue(params) {
  return requestApi({
      url: gptChatUrl.guoXinUrl+'/gptApi/api/v1/connectWisdom/dialogue/addDialogueLog',
      method: 'POST',
      data: params,
    },
  );
/*  return {
    "data": "29c344ad2b53659ceb3b6422b092110e",
    "code": 200,
    "message": "请求成功"
  }*/
}

// 修改会话里的某条聊天记录
export async function editDialogue2(params) {
  return requestApi({
      url: gptChatUrl.guoXinUrl+'/gptApi/api/v1/connectWisdom/dialogue/editDialogueLog',
      method: 'POST',
      data: params,
    },
  );
/*   return {
     "code": 200,
     "message": "修改对话成功",
     "data": null
   }*/
}
// 查询会话详情
export async function dialogueInfo(params) {
  return requestApi({
      url: gptChatUrl.guoXinUrl+'/gptApi/api/v1/connectWisdom/synonymConfig/dialogueInfo',
      method: 'POST',
      data: params,
    },
  );
 /* return {
    "code": 200,
    "message": "修改对话成功",
    "data": null
  }*/
}
// 修改会话本身详情
export async function editDialogue(params) {
  return requestApi({
      url: gptChatUrl.guoXinUrl+'/gptApi/api/v1/connectWisdom/synonymConfig/editDialogue',
      method: 'POST',
      data: params,
    },
  );
/*  return {
    "code": 200,
    "message": "修改对话成功",
    "data": null
  }*/
}

// 查询历史会话列表
export async function dialogueList(params) {
  return requestApi({
      url: gptChatUrl.guoXinUrl+'/gptApi/api/v1/connectWisdom/dialogue/dialogueList',
      method: 'POST',
      data: params,
    },
  );
/*  return {
    "code": 200,
    "message": "对话列表请求成功",
    "data": {
    "thisWeekList": [
      {
        "handleTime": "7月26号",
        "createTime": "2024-05-22 15:56:13",
        "id": "f2ad2a1c1ae186677167b6901a21d8e8",
        "title": "358工作法",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 14:14:35",
        "id": "713f02fe8515280ccbb1ffd17688db20",
        "title": "智慧双推总部活动设置组织优先级、省分活动设置组织优先级、活动优先级为1级，优先展示什么",
        "dialogFlag": "0",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 11:49:58",
        "id": "c761f582a30d70056b9997f9e33e9fc5",
        "title": "周年庆典日日常炒店",
        "dialogFlag": "0",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 11:43:32",
        "id": "4472415b49ee43f8b619716ab09d6fa7",
        "title": "235424524521",
        "dialogFlag": "0",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 11:28:33",
        "id": "9a9b4462ba33727e42e45a2e4c791811",
        "title": "32312321",
        "dialogFlag": "1",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 11:14:52",
        "id": "65d1dd76c998b8d62d4051c08d3a4c70",
        "title": "254254254254",
        "dialogFlag": "1",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 10:59:54",
        "id": "cebf369ebe2607d8d226cd6589c68ea5",
        "title": "fewfew254254",
        "dialogFlag": "0",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 10:51:47",
        "id": "81a337bc6c87c617eab646c0d44708f0",
        "title": "32132132131",
        "dialogFlag": "1",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 10:39:52",
        "id": "ed83f7d736a16f34f5912905ca93e88e",
        "title": "Java冒泡排序",
        "dialogFlag": "1",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 10:38:10",
        "id": "c0536abd8e04b02e00d8946354c18701",
        "title": "11152525",
        "dialogFlag": "0",
      },
      {
        "handleTime": "昨天",
        "createTime": "2024-05-22 10:13:41",
        "id": "c3981a087c139ca794d1a4d2e020ab84",
        "title": "358工作法",
        "dialogFlag": "0",
      },
    ],
      "todayList": [
      {
        "handleTime": "10:4",
        "createTime": "2024-05-23 10:04:23",
        "id": "fcd18b44d14bba19091ce73b1f4dd511",
        "title": "你是谁6dfgdf打發打發反對法地方s打發手動閥手動都是手动挡师德师风水电费第三方是閥手動閥手動閥fgvdsf递四方速递第三方都是水电费水电费水电费是的第三方斯蒂芬？",
        "dialogFlag": "0",
      },
      {
        "handleTime": "9:55",
        "createTime": "2024-05-23 09:55:24",
        "id": "41d93c061eb57a75747c0500adee0ebc",
        "title": "你是谁4？",
        "dialogFlag": "1",
      },
    ]
    }
  }*/
}
